package com.tw.wechart2.util;

import java.util.concurrent.TimeUnit;

import okhttp3.OkHttpClient;

/**
 * @Description: okhttp对象实例化类
 * @Author: lanteng 2020/9/15
 * @Version: 1.0
 */
public class OkHttpUtil {
    private static OkHttpClient instance;

    private OkHttpUtil() {
    }

    public static OkHttpClient getInstance() {
        if (instance == null) {
            synchronized (OkHttpUtil.class) {
                if (instance == null) {
                    instance = new OkHttpClient()
                            .newBuilder()
                            .connectTimeout(30, TimeUnit.SECONDS)
                            .readTimeout(30, TimeUnit.SECONDS)
                            .writeTimeout(30, TimeUnit.SECONDS)
                            .build();
                }
            }
        }
        return instance;
    }



}
